<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

require_once( JPATH_COMPONENT.DS.'controller.php' );
JTable::addIncludePath( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_bpnews'.DS.'tables' );
echo '<div class = "componentheading">BookPeople News</div>';
$controller = new BPNewsController();
$controller->execute( JRequest::getVar( 'task' ) );
$controller->redirect();

// Old, non-MVC code, kept just in case
//jimport( 'joomla.application.helper' );
//require_once( JApplicationHelper::getPath( 'html' ) );
//JTable::addIncludePath( JPATH_ADMINISTRATOR.DS.'components'.DS.$option.DS.'tables' );
//
//switch( $task )
//{
//	case 'view':
//		viewNewsItem( $option );
//		break;
//	default:
//		showPublishedNews( $option );
//		break;
//}
//
//function showPublishedNews( $option )
//{
//	$db =& JFactory::getDBO();
//	$query = "SELECT * FROM #__bpnews WHERE published = '1' ORDER BY created DESC";
//	$db->setQuery( $query );
//	$rows = $db->loadObjectList();
//	if( $db->getErrorNum() )
//	{
//		echo $db->stderr();
//		return false;
//	}
//	
//	HTML_bpnews::showNews( $rows, $option );
//}
//
//function viewNewsItem( $option )
//{
//	$id = JRequest::getVar( 'id', 0 );
//	$row =& JTable::getInstance( 'BPNews', 'Table' );
//	$row->load( $id );
//	if( !$row->published )
//	{
//		JError::raiseError( 404, JText::_( 'Invalid ID provided' ) );
//	}
//	HTML_bpnews::showNewsItem( $row, $option );
//}
//
//
//
//
?>